﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ConsoleApp2.组件;
using 流程测试v1_1.组件;

namespace 流程测试v1_1
{
    public partial class Form1 : Form
    {
        Cylinder cylinder = new Cylinder();
        bool bC1Flag = false;
        public Form1()
        {
            InitializeComponent();
            this.MaximizeBox = false;
            // 设置窗体为固定大小
            this.FormBorderStyle = FormBorderStyle.FixedSingle;

        }
        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
        /// <summary>
        /// 原位屏蔽设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkBox_HomeShiled_CheckedChanged(object sender, EventArgs e)
        {
            cylinder.bHomeShield = !cylinder.bHomeShield;
        }
        /// <summary>
        /// 动位屏蔽设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkBox_WorkShiled_CheckedChanged(object sender, EventArgs e)
        {
            cylinder.bWorkShield = !cylinder.bWorkShield;
        }
        /// <summary>
        /// 执行原点动作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Bt_C1_CylHomeExt_Click(object sender, EventArgs e)
        {
            if (cylinder.ExtHome())
            {
                Bt_C1_CylHomeExt.BackColor = Color.Blue;
                Bt_C1_CylWorkExt.BackColor = Color.LightBlue;
                Work_Light.BackColor = Color.White;
                // 异步Lambda表达式
                Task task = Task.Run(() =>
                {
                    if (cylinder.GetHomeStatus())
                    {
                        Home_Light.BackColor = Color.Green;
                    }
                });
            }
        }
        /// <summary>
        /// 执行动点动作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Bt_C1_CylWorkExt_Click(object sender, EventArgs e)
        {
            if (cylinder.ExtWork())
            {
                Bt_C1_CylHomeExt.BackColor = Color.LightBlue;
                Bt_C1_CylWorkExt.BackColor = Color.Blue;
                Home_Light.BackColor = Color.White;
                // 异步Lambda表达式
                Task task = Task.Run(() =>
                {
                    if (cylinder.GetWorkStatus())
                    {
                        Work_Light.BackColor = Color.Green;
                    }
                });
            }
        }
        /// <summary>
        /// 原位安全状态判定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkBox_HomeSafeSet_CheckedChanged(object sender, EventArgs e)
        {
            cylinder.homeSafe=!cylinder.homeSafe;
        }
        /// <summary>
        /// 动点安全状态判定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkBox_WorkSafeSet_CheckedChanged(object sender, EventArgs e)
        {
            cylinder.workSafe = !cylinder.workSafe;
        }
    }
}
